import { defineStore } from 'pinia'
import type { RouteRecordRaw } from 'vue-router'
import { constantRoutes } from '@/router'

interface PermissionState {
  routes: RouteRecordRaw[]
  dynamicRoutes: RouteRecordRaw[]
}

export const usePermissionStore = defineStore('permission', {
  state: (): PermissionState => ({
    routes: constantRoutes,
    dynamicRoutes: []
  }),
  
  actions: {
    // 设置路由
    setRoutes(routes: RouteRecordRaw[]) {
      this.dynamicRoutes = routes
      this.routes = constantRoutes.concat(routes)
    },
    
    // 重置状态
    resetState() {
      this.routes = constantRoutes
      this.dynamicRoutes = []
    }
  }
}) 